#coding=utf-8
__author__ = 'Meteor'
import  logging
from logging.handlers import RotatingFileHandler
import seting

class Log:
    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(seting.logleve)

        handler = logging.handlers.RotatingFileHandler(r"logs\auto.log",encoding='utf-8',maxBytes=1*10000,backupCount=2)
        handler.setLevel(seting.logleve)

        console_handler = logging.StreamHandler() # 控制台输出
        console_handler.setLevel(seting.logleve)


        fmt = logging.Formatter("%(asctime)s  %(module)s %(funcName) s[%(lineno)s]  %(levelname)s ：%(message)s")
        handler.setFormatter(fmt)
        console_handler.setFormatter(fmt)

        self.logger.addHandler(handler)
        self.logger.addHandler(console_handler)

    def get_log(self):
        return self.logger


logger = Log().get_log()
